-- 流浪汉
--#include "data\functions\Activity\Dart\ApplyDartCommon.lua" once
--#include "data\config\NpcMiscCfg\ZhongBiaoTouCfg.lua" once
--#include "data\functions\GlobalMisc.lua" once

NpcDialog[17] = {}

NpcDialog[17].main = function(sysarg)
	local bSuccess, bcpz, buybx, ybfail, insurance, tAwards1, tAwards2, tAwards3 = SubmitDart(sysarg);
	local tAwards = {tAwards1, tAwards2, tAwards3,};
	if bSuccess == false then
		return;
	end

	local yabiaoCfg = StdActivityCfg[tagActivityType.DBYBActivity];
	if not yabiaoCfg then
		return;
	end
	
	local cfg = ZhongBiaoTouCfg;
	local nJob = Actor.getIntProperty(sysarg, PROP_ACTOR_VOCATION);
	local pack = DataPack.allocPacket(sysarg, LogicCmd.npcDialogSys.sysID, LogicCmd.npcDialogSys.sub.sNpcDlgData)
	if not pack then return; end
	
	DataPack.writeUint64(pack, Actor.getNpc(sysarg));
	DataPack.writeByte(pack, NpcDialogType.ZBTNpcDlg);
	
	local bcName = string.format("{color;%s;%s}", yabiaoCfg.tBiaoche[bcpz].color, yabiaoCfg.tBiaoche[bcpz].monName);
	local Condition1 = string.format(cfg.Condition[1], bcName);
	local Condition2 = "";
	
	-- 是否购买保险
	if buybx == 1 then
		Condition2 = string.format(cfg.Condition[2], "已购");
	else
		Condition2 = string.format(cfg.Condition[2], "未购");
	end

	local strCond = string.format("%s%s", Condition1, Condition2);
	local strDesc = "";

	local nSize = table.getn(cfg.Desc) - 1
	for i=1, nSize do
		local strAwards = string.format(cfg.Desc[i], tAwards[i]);
		strDesc = string.format("%s%s", strDesc, strAwards);
	end
	
	-- 押镖成功, 并且购买了保险
	if buybx == 1 and ybfail == 1 then
		strDesc = string.format("%s%s", strDesc, string.format(cfg.Desc[4], insurance));
	end
	
	local strBtnList = string.format(cfg.continueBtn, "continueDart,8", "");

	DataPack.writeString(pack, strCond);
	DataPack.writeString(pack, strDesc);
	DataPack.writeString(pack, strBtnList);
	DataPack.writeChar(pack, -1);
	DataPack.writeByte(pack, 0);
	DataPack.flush(pack);
end

NpcDialog[17].continueDart = function(sysarg, id)
	Actor.closeNPCDialog(sysarg);
	questTargetSpaceMoveTo(sysarg, id);
end